﻿using CodeGenerator.DBInfo.entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeGenerator.DBInfo
{
    public interface IDBInfoGetter
    {
        /// <summary>
        /// 测试连接数据库
        /// </summary>
        void TestConnection();

        /// <summary>
        /// 获取数据库列表
        /// </summary>
        /// <returns>数据库名称列表</returns>
        List<string> GetDbList();
        /// <summary>
        /// 获取模式列表
        /// </summary>
        /// <param name="dbName">数据库名称</param>
        /// <returns>模式名称列表</returns>
        List<string> GetSchemaList(string dbName);
        /// <summary>
        /// 获取数据表列表
        /// </summary>
        /// <param name="parentName">上级名称，根据数据库类型变化，如果是PostgreSQL则是模式名，MySQL则是数据库名</param>
        /// <returns>表名称列表</returns>
        List<dynamic> GetTableList(string parentName);
        /// <summary>
        /// 获取表的信息
        /// </summary>
        /// <param name="db">数据库名</param>
        /// <param name="schema">模式名</param>
        /// <param name="table">表名</param>
        /// <returns>表信息</returns>
        TableInfo GetTableInfo(string db, string schema, string table);
        /// <summary>
        /// 获取Java类型
        /// </summary>
        /// <param name="column">表字段信息</param>
        /// <returns>Java类型</returns>
        string GetJavaType(ColumnInfo column);
        /// <summary>
        /// 获取JavaScript类型
        /// </summary>
        /// <param name="column">表字段信息</param>
        /// <returns>JavaScript类型</returns>
        string GetJavaScriptType(ColumnInfo column);
    }
}
